

  function animate(obj, target, callback) {

    clearInterval(obj.timer)

    obj.timer = setInterval(function () {
      //1.添加缓速动画
      var step = (target - obj.offsetLeft) / 10
      step = step > 0 ? Math.ceil(step) : Math.floor(step)
      if (obj.offsetLeft == target) {
        clearInterval(obj.timer)
        // if (callback) {
        //   callback()
        // }
        callback && callback()
      }

      obj.style.left = obj.offsetLeft + step + 'px'
    }, 15)

  }

